home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / tutor / pro15 / solution.bas < prev   
Encoding:
BASIC Source File  |  1991-02-02  |  2.3 KB  |  72 lines

  1. 10 'SOLUTION.BAS - One possible solution to the GWBT09 homework assignment!
  2. 20 'NO PEEKING unless you're done or REALLY STUCK!
  3. 30 '
  4. 40 'Our data to be used is as follows:
  5. 50 '
  6. 60 'Last Name:     15 characters
  7. 70 'First Name:    15 characters
  8. 80 'Address:       20 characters
  9. 90 'City:          10 characters
  10. 100 'State:        10 characters
  11. 110 'ZIP code:     10 characters
  12. 120 'Phone number: 13 characters
  13. 130 'Comments:     35 characters
  14. 140 '
  15. 150 'First, we need to open the file and FIELD it so BASIC knows about it...
  16. 160 '
  17. 170 OPEN "ADDRESS.DAT" FOR RANDOM AS #1 LEN=128
  18. 180 FIELD #1,15 AS LASTNAME$,15 AS FIRSTNAME$,20 AS ADDRESS$,10 AS CITY$,10 AS STATE$,10 AS ZIP$,13 AS PHONE$,35 AS COMMENT$
  19. 190 LASTREC=LOF(1)/128
  20. 200 'IMPORTANT - You need to be sure that the number of characters in your FIELD
  21. 210 'statment adds up to the length you told BASIC in the LEN above, otherwise
  22. 220 'you will get all sorts of interesting errors...
  23. 230 '
  24. 240 'Start getting information here...
  25. 250 KEY OFF:CLS
  26. 260 INPUT "Enter a 'Y' to put information in, or 'N' to quit";ANSWER$
  27. 270 IF ANSWER$="Y" OR ANSWER$="y" THEN GOTO 300
  28. 280 'Actually, any answer EXCEPT 'Y' will end the program...
  29. 290 CLOSE:RESET:END
  30. 300 '
  31. 310 'Enter information and save to disk...
  32. 320 PRINT
  33. 330 PRINT "For the address/phone card you are entering, please answer the "
  34. 340 PRINT "following questions:"
  35. 350 PRINT
  36. 360 INPUT "What is the LAST NAME";LSTNAME$
  37. 370 PRINT
  38. 380 INPUT "What is the FIRST NAME";FSTNAME$
  39. 390 PRINT
  40. 400 INPUT "What is the STREET ADDRESS";STADDRESS$
  41. 410 PRINT
  42. 420 INPUT "What is the CITY";CTY$
  43. 430 PRINT
  44. 440 INPUT "What is the STATE";STE$
  45. 450 PRINT
  46. 460 INPUT "What is the ZIP CODE";ZC$
  47. 470 PRINT
  48. 480 INPUT "What is the PHONE NUMBER";PH$
  49. 490 PRINT
  50. 500 INPUT "What COMMENTS should I add";COMM$
  51. 510 PRINT
  52. 520 '
  53. 530 'Ready to save to disk.  Add one to the last record counter, use LSET to put
  54. 540 'the answers where they need to be, then write it out...
  55. 550 '
  56. 560 LASTREC=LASTREC+1
  57. 570 LSET LASTNAME$=LSTNAME$
  58. 580 LSET FIRSTNAME$=FSTNAME$
  59. 590 LSET ADDRESS$=STADDRESS$
  60. 600 LSET CITY$=CTY$
  61. 610 LSET STATE$=STE$
  62. 620 LSET ZIP$=ZC$
  63. 630 LSET PHONE$=PH$
  64. 640 LSET COMMENT$=COMM$
  65. 650 '
  66. 660 'Write the record to disk and see if there are any more...
  67. 670 '
  68. 680 PUT #1,LASTREC
  69. 690 GOTO 250
  70. 700 END
  71. 710 'End of program SOLUTION.BAS from GWBT09 02/01/1991
  72.